﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ErrataParser
{
    internal struct HFError
    {
        public ErrorType Type { get; private set; }

        public int PageNumber { get; private set; }

        public ErrorExtent Extent { get; private set; }

        public string Description { get; private set; }

        public string TypeDescription
        {
            get
            {
                return PrettyPrintErrorType(Type);
            }
        }

        public static string PrettyPrintErrorType(ErrorType errorType)
        {
            switch(errorType)
                {
                    case ErrorType.SeriousTechnicalMistake:
                        return "Major technical mistake";
                    case ErrorType.MinorTechnicalMistake:
                        return "Minor technical mistake";
                    case ErrorType.ImportantLanguageChange:
                        return "Major language or format change";
                    case ErrorType.MinorLanguageChange:
                        return "Minor language or format change";
                    case ErrorType.ReaderQuestionOrClarification:
                        return "Reader-requested clarification";
                    default:
                        return errorType.ToString();
                }
        }

        public static string PrettyPrintErrorExtent(ErrorExtent errorExtent)
        {
            switch (errorExtent)
            {
                case ErrorExtent.FixedInJanuary08Printing:
                    return "Fixed in January 2008 current";
                case ErrorExtent.FixedInApril08Printing:
                    return "Fixed in April 2008 current";
                case ErrorExtent.ConfirmedErrorInCurrentPrinting:
                    return "Confirmed error in current edition";
                case ErrorExtent.UnconfirmedError:
                    return "Unconfirmed error in current edition";
                default:
                    return errorExtent.ToString();
            }
        }

        public HFError(int errorPageNumber, ErrorType errorType, ErrorExtent extentOfError, string errorDescription)
            : this()
        {
            PageNumber = errorPageNumber;
            Type = errorType;
            Extent = extentOfError;
            Description = errorDescription;
        }


        public override string ToString()
        {
            return string.Format("On page #{0}, {1}:\r\n{2}",
                PageNumber, TypeDescription, Description);
        }

        
    } 
}
